package pl.koziolekweb.prusakolep.controllers;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;

import pl.koziolekweb.prusakolep.dao.BugDAO;
import pl.koziolekweb.prusakolep.model.Bug;
import pl.koziolekweb.prusakolep.utils.Reader;

/**
 * 
 * @author koziolek
 *
 *
 * Info: $Id: NewBugActionController.java 119 2009-02-17 22:36:34Z bjkuczynski $
 */
public class NewBugActionController implements Controller {

	BugDAO bugDAO = new BugDAO();

	public void action(Map<String, Object> params) {
		Long id = BugDAO.sequence();
		String file = Reader.read("Podaj nazwę pliku");
		Long line = Long.parseLong(Reader.read("Podaj numer linii"));
		String description = Reader.read("Co spieprzyłeś?");

		Bug bug = new Bug(id, file, line, description);

		try {
			bugDAO.persist(bug);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
